package com.acen.alchol.customui;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.acen.alchol.R;

public class NameListAdapter extends ArrayAdapter<HashMap<String, Object>>{
	
	private Context context;
	private int resource;
	private ArrayList<HashMap<String, Object>> list;
	private LayoutInflater ll;

	public NameListAdapter(Context _context, int _textViewResourceId,
			ArrayList<HashMap<String, Object>> _objects) {
		super(_context, _textViewResourceId, _objects);
		
		this.context = _context;
		this.resource = _textViewResourceId;
		this.list = _objects;
		this.ll = (LayoutInflater)_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		
		if(v == null) {
			v = ll.inflate(resource, null);
		}
		
		TextView tv = (TextView)v.findViewById(R.id.namelist_row_name_tv);
		
		if(tv != null) {
			tv.setText((CharSequence)list.get(position).get("C_name"));
		}
		
		return v;
	}

}
